package com.glasses.primework;

import javax.faces.bean.ManagedBean;
import org.primefaces.model.chart.Axis;
import org.primefaces.model.chart.AxisType;
import org.primefaces.model.chart.ChartSeries;
import org.primefaces.model.chart.HorizontalBarChartModel;

@ManagedBean
public class BarBean {
    private HorizontalBarChartModel model;
    
    public BarBean() {
        model = new HorizontalBarChartModel();
        
        ChartSeries boys = new ChartSeries();
        boys.setLabel("Boys");
        boys.set("2004", 120);
        boys.set("2005", 100);
        boys.set("2006", 44);
        boys.set("2007", 150);
        boys.set("2008", 25);
        
        ChartSeries girls = new ChartSeries();
        girls.setLabel("Girls");
        girls.set("2004", 52);
        girls.set("2005", 60);
        girls.set("2006", 110);
        girls.set("2007", 135);
        girls.set("2008", 120);
        
        model.addSeries(boys);
        model.addSeries(girls);
        model.setTitle("Bar Chart");
        model.setLegendPosition("e");
        model.setStacked(true);
        
        //Axis xAxis = model.getAxis(AxisType.X);
        Axis xAxis = model.getAxis(AxisType.Y);
        xAxis.setLabel("Gender");
        
        //Axis yAxis = model.getAxis(AxisType.Y);
        Axis yAxis = model.getAxis(AxisType.X);
        yAxis.setLabel("Births");
        
        yAxis.setMin(0);
        yAxis.setMax(200);
    }
    
    public HorizontalBarChartModel getModel() {
        return model;
    }
}